<!DOCTYPE html>
<html>

<head>
  <title>vue 组件</title>
  <script src="./static/js/vue.min.js"></script>
</head>

<body>
  <div id="app">
    {{ total }}
    <count ref="b1"></count>
    <count ref="b2"></count>
    <button @click="value">value</button>
  </div>
  <script>
    Vue.component('count', {
      template: '<button v-on:click="inc">{{ count }}</button>',
      data: function () {
        return { count: 0 }
      },
      methods: {
        inc: function () {
          this.count += 1;
        }
      }
    });
    new Vue({
      el: '#app',
      data: {
        total: 1
      },
      methods: {
        value: function () {
          this.total = this.$refs.b1.count + this.$refs.b2.count;
        }
      }
    })
  </script>
</body>

</html>
